package com.example.bootcurriculumproject.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;

import com.example.bootcurriculumproject.util.NumUtil;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    //自动填充器
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"datetime",LocalDateTime.class,LocalDateTime.now());
        this.strictInsertFill(metaObject,"no",String.class,NumUtil.generateValidateCode(1));
        this.strictInsertFill(metaObject,"consignmentnum",String.class,NumUtil.generateValidateCode(2));
        //this.strictInsertFill(metaObject,"cartnum",String.class,NumUtil.generateValidateCode(3));
        this.strictInsertFill(metaObject,"uid",String.class,NumUtil.generateValidateCode(4));
        this.strictInsertFill(metaObject,"addressnum",Integer.class,NumUtil.getAddressID());

    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
